local function GetStringsTable()
    return TUNING.NPC_CHAT_TABLE[ type(TUNING.__NPC_LANGUAGE)=="function" and TUNING.__NPC_LANGUAGE() or TUNING.__NPC_LANGUAGE ] ["npc_event_item_buyer"] or {}
end

STRINGS.CHARACTERS.GENERIC.ACTIONFAIL.SIGN_FOR_SALE = GetStringsTable().action_str_table

local SIGN_FOR_SALE = Action({priority = 70})
SIGN_FOR_SALE.id = "SIGN_FOR_SALE"
SIGN_FOR_SALE.str = GetStringsTable().action_str
SIGN_FOR_SALE.fn = function(act)
	local target = act.target	
	local invobject = act.invobject
	local doer = act.doer
	if  target ~= nil and invobject.components.npc_components_for_sale then
		if target.npc_everything_data == nil then
			return false,"NON_SALE_ITEM"
		end
		local flag , reason = invobject.components.npc_components_for_sale:Check_Target(target)  --- reason 一定要大写
		if flag == true then
			invobject.components.npc_components_for_sale:MessageForPlayer(doer)
			return true
		else
			return false, reason
		end
	end  
	return false,"REFUSED"
end
AddAction(SIGN_FOR_SALE) 
AddComponentAction("USEITEM", "npc_components_for_sale" , function(inst, doer, target, actions) 
	if inst:HasTag("npc_item_sign_for_sale") and target:HasOneOfTags({"heavy","structure"}) and not target:HasTag("player") then
		table.insert(actions, ACTIONS.SIGN_FOR_SALE)
	end
end)
AddStategraphActionHandler("wilson",ActionHandler(ACTIONS.SIGN_FOR_SALE, "dolongaction"))
AddStategraphActionHandler("wilson_client",ActionHandler(ACTIONS.SIGN_FOR_SALE, "dolongaction"))
